﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Ylh.Enums
{
    public class SysConfigSection : ConfigurationSection
    {
        /// <summary>
        /// 数据库类型
        /// </summary>
        [ConfigurationProperty(SysField.DataDbType, DefaultValue = SysDefaultValue.DataDbType)]
        public String DataDbType
        {
            get
            {
                if (base[SysField.DataDbType] == null || String.IsNullOrEmpty(base[SysField.DataDbType].ToString()))
                {
                    base[SysField.DataDbType] = SysDefaultValue.DataDbType;
                }
                return base[SysField.DataDbType].ToString();
            }
            set
            {
                base[SysField.DataDbType] = value;
            }
        }
        /// <summary>
        /// 数据库版本
        /// </summary>
        [ConfigurationProperty(SysField.DbVersion, DefaultValue = SysDefaultValue.DbVersion)]
        public String DbVersion
        {
            get
            {
                if (base[SysField.DbVersion] == null || String.IsNullOrEmpty(base[SysField.DbVersion].ToString()))
                {
                    base[SysField.DbVersion] = SysDefaultValue.DbVersion;
                }
                return base[SysField.DbVersion].ToString();
            }
            set
            {
                base[SysField.DbVersion] = value;
            }
        }
        /// <summary>
        ///连接字符串
        /// </summary>
        [ConfigurationProperty(SysField.ConnectionString, DefaultValue = SysDefaultValue.ConnectionString)]
        public String ConnectionString
        {
            get
            {
                if (base[SysField.ConnectionString] == null || String.IsNullOrEmpty(base[SysField.ConnectionString].ToString()))
                {
                    base[SysField.ConnectionString] = SysDefaultValue.ConnectionString;
                }
                return base[SysField.ConnectionString].ToString();
            }
            set
            {
                base[SysField.ConnectionString] = value;
            }
        }
    }

    public class SysConfigSectionRead : ConfigurationSection
    {
        /// <summary>
        /// 数据库类型
        /// </summary>
        [ConfigurationProperty(SysField.ReadDataDbType, DefaultValue = SysDefaultValue.DataDbType)]
        public String ReadDataDbType
        {
            get
            {
                if (base[SysField.ReadDataDbType] == null || String.IsNullOrEmpty(base[SysField.ReadDataDbType].ToString()))
                {
                    base[SysField.ReadDataDbType] = SysDefaultValue.ReadDataDbType;
                }
                return base[SysField.ReadDataDbType].ToString();
            }
            set
            {
                base[SysField.ReadDataDbType] = value;
            }
        }
        /// <summary>
        /// 数据库版本
        /// </summary>
        [ConfigurationProperty(SysField.ReadDbVersion, DefaultValue = SysDefaultValue.ReadDbVersion)]
        public String ReadDbVersion
        {
            get
            {
                if (base[SysField.ReadDbVersion] == null || String.IsNullOrEmpty(base[SysField.ReadDbVersion].ToString()))
                {
                    base[SysField.ReadDbVersion] = SysDefaultValue.ReadDbVersion;
                }
                return base[SysField.ReadDbVersion].ToString();
            }
            set
            {
                base[SysField.ReadDbVersion] = value;
            }
        }
        /// <summary>
        ///连接字符串
        /// </summary>
        [ConfigurationProperty(SysField.ReadConnectionString, DefaultValue = SysDefaultValue.ReadConnectionString)]
        public String ReadConnectionString
        {
            get
            {
                if (base[SysField.ReadConnectionString] == null || String.IsNullOrEmpty(base[SysField.ReadConnectionString].ToString()))
                {
                    base[SysField.ReadConnectionString] = SysDefaultValue.ReadConnectionString;
                }
                return base[SysField.ReadConnectionString].ToString();
            }
            set
            {
                base[SysField.ReadConnectionString] = value;
            }
        }
    }
}
